﻿@using System.Linq
@using Covenant.Models
@using Covenant.Models.Covenant
@using Microsoft.AspNetCore.Identity
@model IEnumerable<CovenantUser>
@{
    Layout = "_CovenantUserLayout";
    ViewData["Title"] = "Users";
    Dictionary<string, string> UserRoleDict = ViewBag.UserRoleDict;
}
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-2 mb-3">
    <h1 class="h2">Users</h1>
</div>

<div class="table-responsive">
    <table class="table table-hover">
        <thead>
            <tr>
                <th>@Html.DisplayNameFor(model => model.UserName)</th>
                <th>Roles</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {
                if (!UserRoleDict[item.UserName].Contains("Listener") || UserRoleDict[item.UserName].Contains("User"))
                {
                    <tr>
                        <td>
                            <a asp-action="Edit" asp-route-id="@item.Id">
                                @Html.DisplayFor(modelItem => item.UserName)
                            </a>
                        </td>
                        <td>@UserRoleDict[item.UserName]</td>
                    </tr>
                }
            }
        </tbody>
    </table>
</div>
@if (User.IsInRole("Administrator"))
{
    <a class="btn btn-primary" asp-action="Create" role="button"><span data-feather="plus"></span> Create</a>
}
